package mythreads;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
//http://javarevisited.blogspot.in/2013/07/how-to-create-thread-pools-in-java-executors-framework-example-tutorial.html
public class ExecutorExample {

	private static ExecutorService poller = null;
	/** The schedule. */
	private static ScheduledFuture<?> schedule = null;
	public static void main(String[] args) throws InterruptedException, ExecutionException {
		poller = Executors.newScheduledThreadPool(1);
		poller = Executors.newCachedThreadPool();
		//schedule = poller.scheduleAtFixedRate(taskChecker, 1,1000L,TimeUnit.MILLISECONDS);
		Future<?> submit = poller.submit(taskChecker);
		Object x = submit.get();
		poller.shutdown();
	}
	
	private static final Runnable taskChecker = new Runnable() {

		public void run() {
			 System.out.println("hello "+Thread.currentThread().getName());
		}
	};

}
